package mysale.service.impl;

import mysale.dao.FoodDao;
import mysale.dao.impl.FoodDaoImpl;
import mysale.pojo.Food;
import mysale.service.FoodService;
import mysale.util.JDBCUtil;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

/**
 * @author SnakeWoodMan
 * @create 2020-12-24 15:05
 */
public class FoodServiceImpl implements FoodService {

    private Connection conn;
    private FoodDao foodDao = new FoodDaoImpl(conn);

    @Override
    public List<Food> searchAllFood() {
        conn = JDBCUtil.getConnection();
        List<Food> foodList = foodDao.getAllfoodinfo();
//        for (int i = 0; i < foodList.size(); i++) {
//            System.out.println("FoodServiceImpl:List<Food>:" + foodList.get(i).getFoodname());
//        }
//        JDBCUtil.close(conn);
        return foodList;
    }



    public List<Food> selectlikename(String foodname){

        List<Food> foodList = foodDao.selectLikeFoodname(foodname);
//        JDBCUtil.close(conn);
        return foodList;
    }

    @Override
    public List<Food> selectbyfoodtype(String ftid) {
        List<Food> foodList = foodDao.selectbyFtid(ftid);
//        JDBCUtil.close(conn);
        return foodList;
    }

}
